#include <iostream>
#include <ostream>
//
// Created by Asus on 2025/4/16.
//
int func(int a, int b) {
    return a + b;
}

int main() {
    // 数组
    int arr[5] = {1, 2, 3, 4, 5};
    std::cout << arr << std::endl;
    for (int i = 0; i < 5; i++) {
        std::cout << arr[i] << std::endl;
    }

    // 指针
    int num = 10;
    int *ptr = &num;
    std::cout << ptr << " value is: " << *ptr << std::endl;

    // 引用
    int &ref = num;
    ref = 20;
    std::cout << num << std::endl;

    // 调用函数
    int result = func(3, 5);
    std::cout << "sum is " << result << std::endl;


    // 结构体
    struct Point {
        int x;
        int y;
    };
    Point p;
    p.x = 10;
    p.y = 20;
    std::cout << "struct: " << p.x << ", y: " << p.y << std::endl;

    // 类
    class MyClass {
    private:
        int data;

    public:
        MyClass(int value) : data(value) {
        }

        void print() {
            std::cout << "MyClass: " << data << std::endl;
        }
    };
    MyClass obj(30);
    obj.print();


    // 联合体
    union Data {
        int i;
        float f;
    };
    Data d;
    d.i = 10;
    std::cout << "union int: " << d.i << std::endl;
    d.f = 2.5f;
    std::cout << "union float: " << d.f << std::endl;


    // 枚举
    enum Color { RED, GREEN, BLUE };
    Color bule = BLUE;
    Color red = RED;
    std::cout << "enum: " << bule <<  red << std::endl;


    // 类型别名 - typedef
    typedef int MyInt;
    MyInt num1 = 100;
    std::cout << "typedef: " << num1 << std::endl;

    // 类型别名 - using
    using AnotherInt = int;
    AnotherInt num2 = 200;
    std::cout << "AnotherInt: " << num2 << std::endl;

    return 0;
}
